package per.mapt.jedis;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.Pipeline;
import redis.clients.jedis.Response;

import java.io.IOException;
import java.util.Properties;
import java.util.ResourceBundle;

/**
 * 尝试jedis
 * Created by mapeif on 2017/2/28.
 */
public class TryJedis {
    public static void main(String[] args) throws IOException {
        Properties properties = new Properties();
        properties.load(TryJedis.class.getClassLoader().getResourceAsStream("redis.properties"));
        ResourceBundle bundle = ResourceBundle.getBundle("redis");

     //   Jedis jd = new Jedis(bundle.getString("redis.ip"), Integer.parseInt(bundle.getString("redis.port")));
        //TODO 认证不清楚怎么回事
       // jd.auth("admin");

        JedisPool pool = new JedisPool(bundle.getString("redis.ip"), Integer.parseInt(bundle.getString("redis.port")));
        Jedis jd = pool.getResource();
        jd.multi();
      //  jd.multi();
        Pipeline pipe = jd.pipelined();
      //  pipe.multi();
        pipe.set("name", "JackGSmith");
        Response<String> nameWrap = pipe.get("name");
       // System.out.println(nameWrap.get());
        pipe.sync();
        System.out.println(nameWrap.get());
//        System.out.println(nameWrap.get());
        //jd.del("name");
        //System.out.println(jd.get("name"));
        //Response<String> ts = pipe.get("name");

        System.out.println("1231");
    }
}
